package com.yupi.shanoj.judge;

import com.yupi.shanoj.judge.strategy.DefaultStrategy;
import com.yupi.shanoj.judge.strategy.JavaLanguageStrategy;
import com.yupi.shanoj.judge.strategy.JudgeContext;
import com.yupi.shanoj.judge.strategy.JudgeStrategy;
import com.yupi.shanoj.judge.codesandbox.model.JudgeInfo;
import com.yupi.shanoj.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

@Service
public class JudgeManager {

    /**
     * 执行判题
     */
    JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultStrategy();
        if("java".equals(language)){
            judgeStrategy=new JavaLanguageStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
